<% @page_title = @user.display_name -%>

<% content_for :right do -%>
<% if admin? %>
<% if @user.active? %>
  <% form_for @user.moderatorships.build do |f| -%>
    <h6><%= 'Admin &amp; Moderation'[:admin_and_moderation] %></h6>

    <% unless @user.forums.empty? -%>

  	<p><%= 'This user can moderate the following forums.  Click one to remove.'[:remove_moderated_forum] %></p>

    <ul class="flat">
    <% @user.forums.find(:all, :select => "#{Forum.table_name}.*, #{Moderatorship.table_name}.id as moderatorship_id").each do |forum| -%>
      <li>
        <%= link_to forum.name, moderatorship_path(forum.moderatorship_id), :method => :delete, :confirm => "#{'Remove user as moderator for'[:remove_user_as_moderator]} #{forum.name}?" %>
      </li>
    <% end -%>
    </ul>
    <% end -%>

  	<% unless @user.available_forums.empty? -%>
    <p>
  	<label><%= 'Add as moderator'[] %></label><br />
  	<%= f.select :forum_id, @user.available_forums.collect { |forum| [forum.name, forum.id] }, :include_blank => " - " %>
  	</p>
  	<% end -%>

    <p><label><%= check_box_tag :admin, @user.admin? %> <%= 'User is an administrator'[] %></label></p>

    <p>
  		<%= f.submit 'Save'[:save_title] %>
  		<%= f.hidden_field :user_id %>
  	</p>
  <% end -%>
  <p><%= link_to "Suspend user account", suspend_user_path(@user), :method => :put %></p>
<% else %>
  <p><%= "User account is suspended."[] %> <%= link_to "Unsuspend user account", unsuspend_user_path(@user), :method => :put %></p>
  
<% end %>
<p><%= link_to "Edit user account"[], edit_user_path(@user) %></p>
<% end -%>
<% end -%>

<p style="float:right;"><%= avatar_for @user, 80 %></p> 

<h1><%=h @user.display_name %> </h1>

<p class="subtitle">
  <%= feed_icon_tag @user.display_name, formatted_user_posts_path(:user_id => @user, :format => :rss) %>
  <span>
    <%= '{count} topics'[(count=@user.topics.size)==1 ? :topic_count : :topics_count, number_with_delimiter(count)] %>, 
    <%= '{count} posts'[(count=@user.posts.size)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %>
    (<%= 'view'[] %> <%= link_to 'all'[:view_all], user_posts_path(@user) %> | 
    <%= link_to 'monitored'[], "monitored_posts_path(@user)" %> <%= 'posts'[] %>)<br />
  </span>
</p>

<%= @user.bio_html %>

<% unless @user.website.blank? -%>
<p><strong><%= 'Website:'[:website_title] %></strong> <%= sanitize link_to(@user.website.gsub("http://",""), "http://" + @user.website.gsub("http://","")) %>
<% end -%>
<p><%= 'User since'[] %> <%= @user.created_at.to_date.to_s :long %></p>

